/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TableModel;

import Entities.Kendaraan;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Adrian
 */
public class Kendaraan_TableModel extends AbstractTableModel {

    private List<Kendaraan> kendaraans = new ArrayList<Kendaraan>();

    public Kendaraan_TableModel(List<Kendaraan> kendaraans) {
        this.kendaraans = kendaraans;
    }
    public int getRowCount() {
        return kendaraans.size();
    }

    public int getColumnCount() {
        return 4;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Kendaraan kendaraan = kendaraans.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return kendaraan.getNo_polisi();
            case 1:
                return kendaraan.getTipe_kendaraan();
            case 2:
                return kendaraan.getWarna_kendaraan();
            case 3:
                return kendaraan.getTanggal_servis();
            
            default:
                return "";
        }
    }

     @Override
    public String getColumnName(int coloumn) {
        switch (coloumn) {
            case 0:
                return "No Polisi";
            case 1:
                return "Tipe Kendaraan";
            case 2:
                return "Warna Kendaraan";
            case 3:
                return "Tanggal Servis";
           
            default:
                return "";
        }
    }
}
